#! /usr/bin/env python

VERSION = '0.1'
APPNAME = 'render'

srcdir = '.'
blddir = 'build'

import os, sys
import waflib.Options

import waf_ddf, waf_dynamo
import TestContext

test_context = None

def init(ctx):
    global test_context
    if 'build' in waflib.Options.commands:
        test_context = TestContext.create_test_context()

def options(opt):
    opt.recurse('src')
    opt.load('waf_dynamo')

def configure(conf):
    conf.load('waf_dynamo')

    waf_ddf.configure(conf)

    conf.recurse('src')

    platform = conf.env['PLATFORM']

    dynamo_home = os.getenv('DYNAMO_HOME')
    if not dynamo_home:
        conf.fatal("DYNAMO_HOME not set")
    dynamo_ext = os.path.join(dynamo_home, "ext")

    conf.env.append_value('INCLUDES', "../src")
    conf.env.append_value('INCLUDES', os.path.join(dynamo_ext, "include"))
    conf.env.append_value('LIBPATH', os.path.join(dynamo_ext, "lib", platform))
    conf.env.append_value('INCLUDES', os.path.join(dynamo_home, "include" ))
    conf.env.append_value('INCLUDES', os.path.join(dynamo_home, "include", platform))

    conf.env['STLIB_DLIB']          = ['dlib', 'mbedtls', 'zip']
    conf.env['STLIB_DDF']           = 'ddf'
    conf.env['STLIB_RESOURCE']      = 'resource'
    conf.env['STLIB_GRAPHICS']      = ['graphics', 'graphics_proto']
    conf.env['STLIB_GRAPHICS_NULL'] = ['graphics_null', 'graphics_proto']
    conf.env['STLIB_SCRIPT']        = 'script'
    conf.env['STLIB_EXTENSION']     = 'extension'

    conf.env.append_unique('DEFINES', 'DLIB_LOG_DOMAIN="RENDER"')

def build(bld):
    global test_context
    bld.recurse('src')
    TestContext.initialize_test_context(test_context, bld)

def shutdown(self):
    waf_dynamo.run_tests(test_context, valgrind = True)
